<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close" :append-to-body="true" :modal-append-to-body="true">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="150px" :disabled="disableEditSubmit">
      <el-row>
        <el-col :span="12">
          <el-form-item label="里程碑名称" prop="milepostname" :rules="rules.validateRequire">
            <el-input v-model="model.milepostname"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="责任人" prop="responsible" :rules="rules.validateRequire">
            <el-input v-model="model.responsible" :disabled="true" class="tl-ref-selector">
              <el-button slot="append" type="primary" icon="el-icon-search" @click="opensdProjectTeamRefDialog"></el-button>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="计划达成日期" prop="planfinishtime" :rules="rules.validateRequire">
            <el-date-picker v-model="model.planfinishtime" type="date" placeholder="例：2021-01-01" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="交付成果" prop="deliverable" :rules="rules.validateRequire">
            <el-input v-model="model.deliverable"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
    <tlsd-project-team-ref ref="sdProjectTeamRef" @confirm="getSdProjectTeamData" :externalQueryParam="externalQueryParamForPool">
    </tlsd-project-team-ref>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'

/** 子组件 */
import tlsdProjectTeamRef from '@/views/gpm/gpmProjectTeam/refList'
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: { tlsdProjectTeamRef },
  data() {
    return {
      moduleTitle: '项目策划-里程碑',
      urlPrefix: '/sd/projectMilepost/',
      externalQueryParamForPool: {},
      url: {
        // 额外的url
      }
    }
  },
  props: {
    parentId: {
      type: [Number, String],
      default: ''
    },
    operatecode: {
      type: String
    },
    projectinfo: {

    }
  },
  methods: {
    // userConfirm(selectData) {
    //   const selectedUser = selectData[0]
    //   const { code, name } = selectedUser
    //   this.$set(this.model, "responsiblecode", code)
    //   this.$set(this.model, "responsible", name)
    //   this.$set(this.model, "projectcode", this.projectinfo.projectcode)
    // },
    loaded() {
      // 页面加载完毕执行
      if (this.isAdd) {
        this.$set(this.model, 'planid', this.parentId)
      }
    },
    getSdProjectTeamData(selectionRow, selectKey, selectionValue) {
      this.$set(this.model, 'responsiblecode', selectionRow.usercode)
      this.$set(this.model, 'responsible', selectionRow.username)
      this.$set(this.model, "projectcode", this.projectinfo.projectcode)
    },
    opensdProjectTeamRefDialog() {
      this.externalQueryParamForPool = {
        qry_projectcode: this.projectinfo.projectcode,
        qry_state: 9,
        qry_enabled: 1,
        qry_appointmenttype: 1
      }
      this.$refs.sdProjectTeamRef.visible = true
    }
  }
}
</script>

